import { RouterEnum, PermissionsEnum } from '@/enum/index';
import type { RouteRecordRaw } from 'vue-router';

const routes: RouteRecordRaw[] = [
  {
    name: RouterEnum.ADMIN,
    path: '/admin',
    redirect: { name: 'admin.home' },
    component: () => import('@/layouts/admin/index.vue'),
    meta: { auth: true, menu: { title: '网站后台' } },
    children: [
      {
        name: 'admin.home',
        path: '/admin/home',
        component: () => import('@/views/admin/home/index.vue'),
        meta: { menu: { title: '工作台', icon: 'fas fa-house' } },
      },
      {
        name: 'admin.article',
        path: '',
        meta: {
          permissions: [PermissionsEnum.AUTHOR, PermissionsEnum.ADMIN],
          menu: { title: '文章管理', icon: 'fas fa-book' },
        },
        children: [
          {
            name: 'admin.article.list',
            path: '/admin/article/list',
            component: () => import('@/views/admin/article/list/index.vue'),
            meta: { menu: { title: '文章列表', icon: 'fas fa-list-ol' } },
          },
          {
            name: 'admin.article.category',
            path: '/admin/article/category',
            component: () => import('@/views/admin/article/category/index.vue'),
            meta: {
              permissions: [PermissionsEnum.SUPER_ADMIN],
              menu: { title: '栏目管理', icon: 'fas fa-list-check' },
            },
          },
          {
            name: 'admin.article.myself',
            path: '/admin/article/myself',
            component: () => import('@/views/admin/article/myself/index.vue'),
            meta: { menu: { title: '我的文章', icon: 'fas fa-book-open' } },
          },
          {
            name: RouterEnum.ARTICLE_DETAIL,
            path: '/admin/article/detail',
            component: () => import('@/views/admin/article/detail/index.vue'),
          },
          {
            name: RouterEnum.ARTICLE_WRITE,
            path: '/admin/article/write',
            component: () => import('@/views/admin/article/write/index.vue'),
            meta: {
              menu: { title: '写文章', icon: 'fas fa-pen-fancy' },
            },
          },
        ],
      },
      {
        name: 'admin.user',
        path: '',
        meta: { menu: { title: '用户管理', icon: 'fas fa-user' } },
        children: [
          {
            name: 'admin.user.info',
            path: '/admin/user/info',
            component: () => import('@/views/admin/user/info/index.vue'),
            meta: { menu: { title: '账号管理', icon: 'fas fa-user-pen' } },
          },
          {
            name: 'admin.user.list',
            path: '/admin/user/list',
            component: () => import('@/views/admin/user/list/index.vue'),
            meta: {
              permissions: [PermissionsEnum.ADMIN],
              menu: { title: '用户列表', icon: 'fas fa-user-group' },
            },
          },
          {
            name: 'admin.user.roles',
            path: '/admin/user/roles',
            component: () => import('@/views/admin/user/roles/index.vue'),
            meta: {
              permissions: [PermissionsEnum.SUPER_ADMIN],
              menu: { title: '角色列表', icon: 'fas fa-user-tag' },
            },
          },
        ],
      },
    ],
  },
];

export default routes;
